import { BasicFetchResult } from '/@/api/model/baseMode';
import { RoleItem, RoleListQueryParams } from './model/roleModel';
import { defHttp } from '/@/utils/http/axios';

import { ErrorMessageMode } from '/@/utils/http/axios/types';

enum Api {
  List = '/system/role/list',
  Add = '/system/role',
  Delete = '/system/role/',
}

/**
 * @description: 角色列表查询
 */
export function listApi(params: RoleListQueryParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<RoleItem>>(
    {
      url: Api.List,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 新增用户
 */
export function AddApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.Add,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 编辑用户
 */
export function EditApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.put(
    {
      url: Api.Add,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 删除用户
 */
export function DeleteApi(roleId: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.delete(
    {
      url: Api.Delete + `${roleId}`,
    },
    {
      errorMessageMode: mode,
    }
  );
}
